import { InputQuestion, QuestionBase, SelectQuestion, TableBase, TextTable, TimeQuestion } from '@/components/public-template';
import { Api } from '@/config/api/statement';
import { Api as ApiArchives } from '@/config/api/archives';
import { regExp } from '@/utils/regExp';

class HomeService {
  getQuestions() {
    const questions: QuestionBase<any>[] = [
      new SelectQuestion({
        key: 'inventoryRange',
        label: '盘点范围',
        type: 'tree',
        state: {
          url: ApiArchives.folderTree,
          multiple: true,
          nameKey: 'name',
          nameValue: 'id',
          nameChildren: 'children',
          protType: 'post'
        }
      })
    ];
    return questions;
  }
  getTables() {
    const tables: TableBase<any>[] = [
      new TextTable({
        key: 'num',
        value: '序号',
        type: 'index'
      }),
      new TextTable({
        key: 'folderName',
        value: '盘点范围'
      }),
      new TextTable({
        key: 'needInventoryNum',
        value: '应盘数量'
      }),
      new TextTable({
        key: 'actualInventoryNum',
        value: '实盘数量'
      }),
      new TextTable({
        key: 'passNum',
        value: '通过数量'
      }),
      new TextTable({
        key: 'failNum',
        value: '不通过数量'
      }),
      new TextTable({
        key: 'expirationReminder',
        value: '计划结束日期'
      }),
      new TextTable({
        key: 'actuallyEndsTime',
        value: '实际结束日期'
      }),
      new TextTable({
        key: 'inventoryUserName',
        value: '盘点负责人'
      }),
      new TextTable({
        key: 'actions',
        value: '操作',
        columns: {
          fixed: 'right',
          width: 180
        },
        handle: [
          {
            type: 'local',
            text: '盘点明细',
            class: 'text-primary',
            params: [{ id: 'id' }],
            state: {}
          }
        ]
      })
    ];
    return tables;
  }
  getDetailTables() {
    const tables: TableBase<any>[] = [
      new TextTable({
        key: 'num',
        value: '序号',
        type: 'index'
      }),
      new TextTable({
        key: 'borrowType',
        value: '借阅类型',
        type: 'dictionary',
        state: {
          filterName: 'DMS_ARCHIVES_FILE_BORROW_BORROW_TYPE'
        }
      }),
      new TextTable({
        key: 'borrowCode',
        value: '借阅编码'
      }),
      new TextTable({
        key: 'test',
        value: '是否借阅原件',
        type: 'dictionary',
        state: {
          filterName: 'YES_OR_NO'
        }
      }),
      new TextTable({
        key: 'borrowTime',
        value: '借阅时间'
      }),
      new TextTable({
        key: 'renewTime',
        value: '续借时间'
      }),
      new TextTable({
        key: 'planReturnTime',
        value: '计划归还时间'
      }),
      new TextTable({
        key: 'actualReturnTime',
        value: '实际归还时间'
      }),
      new TextTable({
        key: 'isOverdue',
        value: '是否逾期',
        type: 'dictionary',
        state: {
          filterName: 'IS_OVERDUE'
        }
      })
    ];
    return tables;
  }
  getIcons() {
    const icons: TableBase<any>[] = [
      new TextTable({
        key: 'select',
        value: '导出',
        options: [
          {
            key: 'local',
            label: '导出选中',
            state: {}
          },
          {
            key: 'download',
            label: '导出全部',
            state: {
              type: 'all',
              url: Api.exportAllInventoryTaskReportForm,
              fileName: '盘点任务记录报表.xlsx'
            }
          }
        ]
      })
    ];
    return icons;
  }
}

export default new HomeService();
